@extends('layouts.default') @section('main')
    <link rel="stylesheet" href="{{URL::asset('js/')}}/kindeditor-4.1.7/themes/default/default.css" />
    <link rel="stylesheet" href="{{URL::asset('js/')}}/kindeditor-4.1.7/plugins/code/prettify.css" />
    <script src="{{URL::asset('js/')}}/kindeditor-4.1.7/kindeditor.js" type="text/javascript"></script>
    <script charset="utf-8" src="{{URL::asset('js/')}}/kindeditor-4.1.7/lang/zh_CN.js"></script>
    <script charset="utf-8" src="{{URL::asset('js/')}}/kindeditor-4.1.7/plugins/code/prettify.js"></script>
    <script type="text/javascript" src="{{URL::asset('js/')}}/ajaxfileupload.js"></script>
    <script type="text/javascript" src="{{URL::asset('js/')}}/common.js"></script>
    <script src="{{URL::asset('js/My97DatePicker/')}}/WdatePicker.js"></script>

    <script>
        KindEditor.ready(function(K) {

            var editor1 = K.create('#activity_content,#activity_summary,#activity_remark', {
                uploadJson: "{{url('kindedit/upload')}}",
                fileManagerJson: "{{url('kindedit/manager')}}",
                allowFileManager: true,
                afterBlur: function() {
                    this.sync();
                },
                items: ['source', '|', 'undo', 'redo', '|', 'cut', 'copy', 'paste', 'justifyleft', 'justifycenter', 'justifyright', 'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript', 'superscript', 'clearhtml', 'quickformat', 'selectall', 'image', '/', 'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|', 'table', 'hr', 'emoticons', 'pagebreak', 'anchor', 'link', 'unlink', '|']
            });

        });
    </script>
    <div id="content">
        <div id="content-header">
            <div id="breadcrumb">
                <a href="{{url('home')}}" title="返回首页" class="tip-bottom"><i
                            class="icon-home"></i> 首页</a>
                <a href="{{url('news/list')}}" class="tip-bottom">资讯管理</a>
                <a href="#" class="current">创建资讯</a>
            </div>
        </div>
        <div class="container-fluid">
            <div class="row-fluid">
                <div class="span11">
                    <div class="widget-box">
                        <div class="widget-title">
						<span class="icon"> <i class="icon-align-justify"></i>
						</span>
                            <h5>创建一条资讯</h5>
                        </div>
                        <div class="widget-content nopadding">
                            <form action="{{url('news/create')}}" id="adForm" method="post" class="form-horizontal">
                                {{--<div class="control-group">--}}
                                    {{--<label class="control-label">标题 :</label>--}}
                                    {{--<div class="controls">--}}
                                        {{--<input type="text" class="span11" name="title" placeholder="标题" />--}}
                                    {{--</div>--}}
                                {{--</div>--}}
                                <div class="control-group">
                                    <label class="control-label"><span class="redD">*</span>主题 :</label>
                                    <div class="controls">
                                        <input type="text" class="span11" name="subject" placeholder="主题" />
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label"><span class="redD">*</span>描述 :</label>
                                    <div class="controls">
                                        <input type="text" class="span11" name="description" placeholder="描述" />
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label"><span class="redD">*</span>前台是否可见 :</label>
                                    <div class="controls">
                                        <select name="status">
                                            <option value="">请选择</option>
                                            <option value="0">不可见</option>
                                            <option value="1">可见</option>
                                        </select>
                                    </div>
                                </div>

                                <div class="control-group">
                                    <label class="control-label"><span class="redD">*</span>所属分类 :</label>
                                    <div class="controls">
                                        <select name="category_id">
                                            <option value="">请选择</option>
                                            @foreach($cats as $category)
                                                <option value="{{$category->id}}">{{$category->name}}</option>
                                            @endforeach
                                        </select>
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label"><span class="redD">*</span>来源 :</label>
                                    <div class="controls">
                                        <input type="text" class="span11" name="source" placeholder="来源" />
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label"><span class="redD">*</span>来源url :</label>
                                    <div class="controls">
                                        <input type="text" class="span11" name="source_url" placeholder="标题url" />
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label"><span class="redD">*</span>版权 :</label>
                                    <div class="controls">
                                        <input type="text" class="span11" name="copyrights" placeholder="版权" />
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label"><span class="redD">*</span>关键词 :</label>
                                    <div class="controls">
                                        <input type="text" class="span11" name="keyword" placeholder="关键词，以逗号隔开" />
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label">缩略图 :</label>
                                    <div class="controls">
                                        <input type="hidden" class="span11" name="thumb"  placeholder="点击右边小图标上传" />
                                        <img src="" width="120px" name="thumb" height="120px"/>

                                        <a href="javascript:void(0);" id="uploadBgimgBtn"   onclick="javascript:openBrowse('uploadBgimgBtn','uploadBgimg');">点击上传</a>
                                        <input type="file" id="uploadBgimg" style="display:none" name="myfile" size="10" onchange="fileUpload('uploadBgimg','thumb')"/>
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label"><span class="redD">*</span>内容 :</label>
                                    <div class="controls">
                                        <textarea id="activity_content" name="content" style="width: 450px; height: 240px;" placeholder="请输入资讯类容"></textarea>
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label">发布时间 :</label>
                                    <div class="controls">
                                        <input type="text" class="span11" name="pubdate"
                                               placeholder="发布时间" value="{{date('Y-m-d H:i:s')}}" onfocus="WdatePicker({startDate:'%y-%M-01 00:00:00',dateFmt:'yyyy-MM-dd HH:mm:ss',alwaysUseStartDate:true})" />
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label">是否推荐 :</label>
                                    <div class="controls">
                                        <select name="recommend">
                                            <option value="">请选择</option>
                                            <option value="0">不推荐</option>
                                            <option value="1">推荐</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label">排序 :</label>
                                    <div class="controls">
                                        <input type="text" class="span11" name="sort" placeholder="排序" />
                                    </div>
                                </div>


                                <input type="hidden" class="span11" name="formType" value="create" />
                                <div class="form-actions">
                                    <input type="hidden" name="_token" value="{{ csrf_token() }}">
                                    <button type="button" id="doSave" class="btn btn-success">确认修改</button>
                                </div>
                            </form>
                            @include('errors.list')
                            @include('message.flash')
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script>
        $("#doSave").click(function(){
            $(this).attr('disabled','disabled');
            ajaxRequest($('#adForm').serializeArray(),$('#adForm').attr('action'),function(data){
                if(data.status){
                    alert(data.message);
                    window.location.href = data.forwardUrl;
                }else{
                    $("#doSave").removeAttr('disabled');

                    alert(data.message);
                }
            });
        });
    </script>
@stop
